::config_begin
set WIN_GIT_HOME=C:\Program Files\Git\git-bash.exe
set UNIX_IMAGE_HOME=/c/hzz/typora_images
set GITEE_USER=why0406
set GITEE_PROJECT=typora_images
set GITEE_PATH=master/images
set TMP_FILE=tmp_file_path.txt
::config_end

::获取标准路径 C:\typora\images\Thrift 网络栈\a.png
set image_path=%~f1
::获取文件名及扩展名 a.png
set image_name=%~nx1
::获取脚本路径下的临时文件 C:\hzz\typora_images\tmp_file_path.txt
set tmp_file=%~dp0%TMP_FILE%

:: start 启动 git-bash 执行 -c 指定的多个参数命令
:: /wait 等待 start 返回后在往下执行
:: 第一个双引号用于解决 WIN_GIT_HOME 路径存在空格的问题
start /wait "" "%WIN_GIT_HOME%" -c "cd %UNIX_IMAGE_HOME% && sh upload.sh "%1""

::读取临时文件的内容 parent_dir="Thrift 网络栈" 转码后 "Thrift%20%E7%BD%91%E7%BB%9C%E6%A0%88"
for /F "tokens=*" %%i IN (%tmp_file%) DO set "parent_dir=%%i"
del  %tmp_file%

::blob需要替换为raw
::public库地址
echo https://gitee.com/%GITEE_USER%/%GITEE_PROJECT%/raw/%GITEE_PATH%/%parent_dir%/%image_name%